import { fileURLToPath, URL } from 'node:url';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueDevTools from 'vite-plugin-vue-devtools';
// const DevDomain = 'http://localhost:8082/';
// const Domain = DevDomain;
const ReleaseDomain = 'http://8.134.197.118:8082/';
const Domain = ReleaseDomain;
// https://vite.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        api: 'modern-compiler', //解决在viet创建的项目中引入的sass过时
      },
    },
  },
  plugins: [vue(), vueDevTools()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      'react-dom/client': resolve(__dirname, './src/client.ts'),
    },
  },
  server: {
    // 允许跨域
    cors: true,
    // 监听所有地址
    host: '0.0.0.0',
    // 本地跨域代理-> 代理到服务器的接口地址
    proxy: {
      '/admin-api/': {
        target: Domain, //代理接口\
        changeOrigin: true,
      },
    },
  },
});
